{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Episode 07: Way up here.\n",
    "\n",
    "### This notebook shows how you can see some basic information about all Metaflow flows that you've run. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Import the metaflow client"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from metaflow import Metaflow, Flow, get_metadata\n",
    "print(\"Current metadata provider: %s\" % get_metadata())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## List all flows with their latest completion time and status"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for flow in Metaflow():\n",
    "    run = flow.latest_run\n",
    "    print(\"{:<15} Last run: {} Successful: {}\".\\\n",
    "          format(flow.id, run.finished_at, run.successful))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Give some detailed information on HelloAWSFlow"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "\n",
    "flow = Flow('HelloAWSFlow')\n",
    "runs = list(flow.runs())\n",
    "print(\"HelloAWSFlow:\")\n",
    "for run in runs:\n",
    "    print(\"Run id: {}, Successful: {}\".format(run.id, run.successful))\n",
    "    print(\"Tags: {}\\n\".format(sorted(list(run.tags))))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
